import 'package:flutter/material.dart';

import 'package:bloc_pattern/bloc_pattern.dart';
import 'package:xxx_app/src/blocs/increment/increment_bloc.dart';


class MineScreen extends StatelessWidget {
  

  @override
  Widget build(BuildContext context) {
    final IncrementBloc incrementBloc = BlocProviderList.of<IncrementBloc>(context);

    return Scaffold(
      appBar: AppBar(
        title: Text(
          "我的",
          
        ),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          // mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            
            StreamBuilder(
              stream: incrementBloc.outScreen,
              builder: (BuildContext context, AsyncSnapshot snapshot) {
                  return Text("点击次数 ${snapshot.data} vezes");

              },
            ),
            Text(
              "Mine",
              style:TextStyle(
                fontSize: 32
              )
            )

            

          ],

        ),
      ),
      floatingActionButton: FloatingActionButton(
         onPressed: () {
           incrementBloc.increment();

         },
        tooltip: 'Increment',
        child: new Icon(Icons.add),
      ),
    );

  }
}


/*
class MineScreen extends StatefulWidget {
  @override
  _MineScreenState createState() => _MineScreenState();
}

class _MineScreenState extends State<MineScreen> with AutomaticKeepAliveClientMixin<MineScreen> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() { 
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    
    return new Scaffold(
      appBar: AppBar(
        title: Text(
          "我的",
          
        ),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text(" mine 点击次数: "),
            new Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        )
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: new Icon(Icons.add),
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
  
}

*/
